#import <Foundation/Foundation.h>
#import "DFCommandParser.h"
#import "DFDiff.h"
#import "DFFunctionGenerator.h"


void printc(NSArray *commands) {
	// print out some info about the first command
	DFCommand *command = [commands objectAtIndex:0];
	NSString *output;
	
	NSLog(command.name);
	NSLog(@"Parameters:");
	for (DFParameter *p in [command getParameters]) {
		if (p.useInResponse) { output = @"[Returned]"; }
		else { output = @""; }
		
		
		NSLog(@"%@ [%@] %@", p.name, [DFParameter getStringFromType:p.type], output);
	}
	
	NSLog(@"Return Parameters:");
	for (DFParameter *p in [command getReturnParameters]) {
		NSLog(@"%@ [%@]", p.name, [DFParameter getStringFromType:p.type]);
	}
}


int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // to start of we are just going to expect a file name as an arg
	if (argc>=3) {
		NSString *path = [[NSString alloc] initWithCString:argv[1] encoding:NSASCIIStringEncoding]; 
		DFCommandParser *parser = [[DFCommandParser alloc] initWithPath:path];
		
		NSLog(@"Parsing xml document");
		
		NSArray *commands1 = [parser parse];
		
		
		
		/*NSString *path2 = [[NSString alloc] initWithCString:argv[2] encoding:NSASCIIStringEncoding]; 
		DFCommandParser *parser2 = [[DFCommandParser alloc] initWithPath:path2];
		
		NSLog(@"Parsing second xml document");		
		
		NSArray *commands2 = [parser2 parse];
		
		NSLog(@"Doing diff");
		
		DFDiff *diff = [[DFDiff alloc] init];
		
		[diff run:commands1 :commands2];*/
		
		DFFunctionGenerator *gen = [[DFFunctionGenerator alloc] init];
		
		[gen writeToDirectory:@"/Users/tombooth/" :commands1];
		
		
	}
	else { NSLog(@"You have not provided enough parameters"); }

	
    [pool drain];
    return 0;
}